package main

import (
	"cat/proto/pb"
	"context"
	"fmt"
	"google.golang.org/grpc"
	"net"
)

type Greeter struct {
}

func (s *Greeter) SayHello(ctx context.Context, rep *pb.HelloRequest) (*pb.HelloReply, error) {
	fmt.Println("into sayHello start...")
	fmt.Println(rep)
	reply := &pb.HelloReply{Message: "hello world"}
	return reply, nil
}

func main() {
	listen, err := net.Listen("tcp", "127.0.0.1:9990")
	if err != nil {
		fmt.Println("err")
		return
	}
	server := grpc.NewServer()
	pb.RegisterGreeterServer(server, &Greeter{})

	fmt.Println("start grpc......")
	err = server.Serve(listen)
	if err != nil {
		fmt.Println(err)
	}
}
